from typing import Optional


class Config:
    instance: Optional['Config'] = None

    def __init__(self, sAppId=None, sToken=None, sEncodingAESKey=None, sCorpID=None, corpSecret=None, user="admin",
                 password="admin", db_host="localhost", db_password=None, redis_host="localhost", redis_password=None,ai_url=None):
        self.sAppId = sAppId  # 企业微信应用的ID
        self.sToken = sToken  # 企业微信应用的Token
        self.sEncodingAESKey = sEncodingAESKey  # 企业微信应用的EncodingAESKey
        self.sCorpID = sCorpID  # 企业微信的企业ID
        self.corpSecret = corpSecret  # 企业微信应用的secret也作为身份验证的密钥
        self.user = user  # 后台管理员的用户名
        self.password = password  # 后台管理员的密码
        self.db_host = db_host  # 数据库的主机地址
        self.db_password = db_password  # 数据库的密码
        self.redis_host = redis_host  # Redis的主机地址
        self.redis_password = redis_password  # Redis的密码
        self.ai_url = ai_url  # AP接口
        if Config.instance is None:
            Config.instance = self

    def get_ai_url(self):
        return self.ai_url

    def set_ai_url(self, ai_url):
        self.ai_url = ai_url
        
    def get_sAppId(self):
        return self.sAppId

    def set_sAppId(self, sAppId):
        self.sAppId = sAppId

    def get_sToken(self):
        return self.sToken

    def set_sToken(self, sToken):
        self.sToken = sToken

    def get_sEncodingAESKey(self):
        return self.sEncodingAESKey

    def set_sEncodingAESKey(self, sEncodingAESKey):
        self.sEncodingAESKey = sEncodingAESKey

    def get_sCorpID(self):
        return self.sCorpID

    def set_sCorpID(self, sCorpID):
        self.sCorpID = sCorpID

    def get_corpSecret(self):
        return self.corpSecret

    def set_corpSecret(self, corpSecret):
        self.corpSecret = corpSecret

    def get_user(self):
        return self.user

    def set_user(self, user):
        self.user = user

    def get_password(self):
        return self.password

    def set_password(self, password):
        self.password = password

    def get_db_host(self):
        return self.db_host

    def set_db_host(self, db_host):
        self.db_host = db_host

    def get_db_password(self):
        return self.db_password

    def set_db_password(self, db_password):
        self.db_password = db_password

    def get_redis_host(self):
        return self.redis_host

    def set_redis_host(self, redis_host):
        self.redis_host = redis_host

    def get_redis_password(self):
        return self.redis_password

    def set_redis_password(self, redis_password):
        self.redis_password = redis_password


Config.instance = Config(corpSecret="09d25e094faa6ca2556c818166b7a95632b94f0ab4f05689d195e5142c95d9e3")

if __name__ == '__main__':
    c = Config(user="admin1", password="admin2")
    c.sToken = "123"
    print(Config.instance.get_user())
